import 'package:flutter/material.dart';
import 'package:flutter_enjoy/pages/home/home_page.dart';
import 'package:flutter_enjoy/pages/mine/my_page.dart';

class TabsPage extends StatefulWidget {
  const TabsPage({super.key});

  @override
  // ignore: library_private_types_in_public_api
  _TabsPageState createState() => _TabsPageState();
}

class _TabsPageState extends State<TabsPage> {
  int currentActiveIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: IndexedStack(
        index: currentActiveIndex,
        children: const [
          HomePage(),
          MyPage(),
        ],
      ),
      bottomNavigationBar: BottomNavigationBar(
        onTap: (current) => {
          setState(() {
            currentActiveIndex = current;
          })
        },
        type: BottomNavigationBarType.fixed,
        currentIndex: currentActiveIndex,
        selectedFontSize: 12,
        selectedIconTheme: const IconThemeData(color: Color(0xff598fa5)),
        selectedItemColor: const Color(0xff598fa5),
        unselectedIconTheme: const IconThemeData(color: Color(0xffb2b2b2)),
        unselectedItemColor: const Color(0xffb2b2b2),
        items: [
          BottomNavigationBarItem(
              icon: Image.asset(
                'assets/tabs/home_default.png',
                width: 24,
                height: 24,
              ),
              activeIcon: Image.asset(
                'assets/tabs/home_active.png',
                width: 24,
                height: 24,
              ),
              label: '首页'),
          BottomNavigationBarItem(
              icon: Image.asset(
                'assets/tabs/my_default.png',
                width: 24,
                height: 24,
              ),
              activeIcon: Image.asset(
                'assets/tabs/my_active.png',
                width: 24,
                height: 24,
              ),
              label: '我的'),
        ],
      ),
    );
  }
}
